package com.tf_cut.backend.util;

import com.tf_cut.backend.agent.vo.AgentCashOrderVo;
import com.tf_cut.backend.payment.service.PaymentService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class AutoPaymentTask {
    private Logger logger = LogManager.getLogger(AutoPaymentTask.class);
    private int round = 0;

    @Resource
    private PaymentService payment;

    //每隔3秒发送一次支付请求
//    @Scheduled(fixedDelay = 3000)
//    public void payMoney() {
//        logger.info("支付当前队列个数：" + OrderPaymentQueue.size());
//
//        try {
//            if(OrderPaymentQueue.size()>0) {
//                Object obj = OrderPaymentQueue.get();
//
//                if (obj instanceof String) {
//                    //发放的支付是基于发放订单的订单号自动获取所有该订单号下明细支付
//                    int res = payment.paymentSellerProvide(obj.toString());
//                } else if (obj instanceof AgentCashOrderVo) {
//                    //代理商提现
//                    AgentCashOrderVo cash = (AgentCashOrderVo) obj;
//
//                    int res = payment.paymentAgentCash(cash);
//                }
//            }
//
//        }catch (Exception e){
//            logger.error("支付查询出错",e);
//        }
//        logger.info("队列剩余待查询订单个数：" + QueryPaymentQueue.size());
//    }
}
